#include "stdafx.h"
#include "Penguin.h"
#include "fmodproj.h"
#include <windows.h>
#include "SphereComponent.h"
#include <sstream>

void Penguin::updateLogic() {
	if(m_sound)	{
		m_sound->setPos(m_node->getPosition().x, m_node->getPosition().y, m_node->getPosition().z);
	}
}

Penguin::Penguin(Ogre::Vector3 position) {
	m_sound = NULL;
	m_physicsComponent = new SphereComponent(position, 1, 100, true);
}

Penguin::~Penguin() {
	//TODO delete node?
	delete m_sound;
}

void Penguin::createMovableObject(Ogre::SceneManager* sceneMgr, unsigned int id) {

	std::stringstream out;
	out << "PenguinEntity" << id;
	std::string idString = out.str();

	Ogre::Entity* entity = sceneMgr->createEntity(idString, "penguin.mesh");
	this->addMovableObject(entity);
	m_node->attachObject(entity);
	m_node->scale(Ogre::Vector3(1, 1, 1)/20);
}

void Penguin::addedToModel() {
	m_sound = new Sound3d(EVENTID_FMODPROJ_SFX_FOOTSTEP, m_node->getPosition().x, m_node->getPosition().y, m_node->getPosition().z);
	m_sound->play();
}